package simulations.factory;

import simulations.Simulation;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Factor for setting the Simulation's global forces
 * @author Zach Michaelov
 */
public class EnvironmentFactory {
    public static void fromFile(File modelFile, Simulation sim) {
        try {
            Scanner input = new Scanner(modelFile);
            while (input.hasNext()) {
                Scanner line = new Scanner(input.nextLine());
                if (line.hasNext()) {
                    ForceFactory.fromScanner(line, sim);
                }
            }
            input.close();
        } catch (FileNotFoundException e) {
            // should not happen because File came from user selection
            e.printStackTrace();
        }
    }

}
